package m.jclecai.com.base;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.widget.Toast;

import butterknife.ButterKnife;


public abstract class MyBaseActivity extends AppCompatActivity {
	public Activity mContext;
	public Bundle bundle;

	public abstract int getActivityInfo();
	/**
	 * 
	 * @return 布局id
	 */
	protected abstract int getLayoutId();

	/**
	 * 初始化控件
	 */
	protected abstract void initWidget();

	/**
	 * 事件绑定
	 */
	protected abstract void eventOnClick();

	/**
	 * 初始化数据
	 */
	protected abstract void initData();
	
    /**
     * 重写此方法，发起异步异步请求
     * @param
     */
    protected abstract void  sendHttpRequest(int taskId);

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(getLayoutId());
		mContext = this;
		bundle = getIntent().getExtras();
		ButterKnife.bind(this);
		initWidget();
		eventOnClick();
		initData();
	}

	@SuppressWarnings("unchecked")
	public <T extends View> T getViewById(int id) {
		View view = findViewById(id);
		return (T) view;
	}

	public void showToast(final String text) {
		runOnUiThread(new Runnable() {
			@Override
			public void run() {
				Toast.makeText(mContext, text, Toast.LENGTH_LONG).show();
			}
		});
	}
	
    public void goActivity(Class<?> descClass, Bundle bundle){

    }



}
